<include file="Public/header" />
    <div class="comm-top">
    	<include file="Goods/nav" act_nav="index"/>
        <div class="title-left">整车列表</div>
        <div class="title-right" style="top:8px;">
        <form method="get" action="{:U('index')}">
            <input name="keywords" class="textarea search_inp" placeholder="请输入关键词" type="text" value="{:I('get.keywords')}"/>
            <input value="搜索" class="btn btn-success search_btn" type="submit" />
<!--             <input value="添加商品" class="btn btn-success search_btn" type="button" onclick="location.href='{:U('add')}'" /> -->
        </form>
        </div>
    </div>
    <div class="list-table">
        <div class="wrapper">
            <table class="stable">
                <thead>
                    <tr>
                        <th>LOGO</th>
                        <th>名称</th>
                        <th>价格</th>
                        <th>销量</th>
                        <th>库存</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <foreach name="list" item="vo">
                        <tr>
                            <td class="img_td"><div style="background:url('{$vo.goods_logo}') no-repeat center;background-size:cover;"></div></td>
                            <td>{$vo.goods_name|default='--'}</td>
                            <td>{$vo.price|default='--'}</td>
                            <td>{$vo.sale_count|default=0}</td>
                            <td>{$vo.store|default=0}</td>
                            <if condition="$vo.status eq '1'">
                                <td class="staTd" data-id="{$vo.id}"><span class="staAct">上架</span> | <span data-status="2">下架</span></td>
                            <else />
                                <td class="staTd" data-id="{$vo.id}"><span data-status="1">上架</span> | <span class="staAct">下架</span></td>
                            </if>
                            <td><div class="btn-operate">
                                <a href="{:U('add_goods',array('id'=>$vo['id']))}" title="修改"><i class="glyphicon glyphicon-edit"></i></a>
                                <a href="javascript:void(0);" onclick="delRow('{$vo.id}',this)" title="删除" id="delBtn{$vo.id}"><i class="glyphicon glyphicon-trash"></i></a>
                            </div></td>
                        </tr>
                    </foreach>
                </tbody>
            </table>
        </div>
    </div>
    <div class="page-list">{$page}</div>
<script type="text/javascript">
$(function(){
    $('.staTd span').click(function(){
        if($(this).hasClass('staAct')) return;
        $.post("{:U('set_status')}",{id:$(this).parent().attr('data-id'),status:$(this).attr('data-status')},function(){
            location.reload();
        });
    });
});
function delRow(id,obj){
    if(confirm('确定要删除吗？')){
        $.post("{:U('dele_data')}",{id:id},function(res){
            if(res.status == 1){
                note_info(res.info,obj);
                setTimeout('location.reload()',1200);
            }else{
                note_info(res.info,obj,'warn');
            }
        },'json');
    }
}
</script>
<include file="Public/footer" />